
package com.jf.cloud.multishop.mapper;

import com.jf.cloud.multishop.model.ShopWalletZone;
import com.jf.cloud.multishop.vo.ShopWalletVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 
 * 店铺钱包分片
 * @author zz
 */
public interface ShopWalletZoneMapper {

    /**
     * 更新
     * @param shopWalletZone 
     */
    void update(@Param("shopWalletZone") ShopWalletZone shopWalletZone);

    /**
     * 批量保存
     * @param shopWalletZoneList
     */
    void batchSave(@Param("shopWalletZoneList") List<ShopWalletZone> shopWalletZoneList);

    /**
     * 批量更新
     * @param shopWalletZoneList
     */
    void batchUpdate(@Param("shopWalletZoneList") List<ShopWalletZone> shopWalletZoneList);

    /**
     * 给商家钱包，添加未结算金额
     *
     * @param shopId
     * @param changeAmount
     * @param zoneNo
     * @return
     */
    int addUnsettledAmount(@Param("shopId") Long shopId, @Param("changeAmount") Long changeAmount, @Param("zoneNo") Integer zoneNo);

    /**
     * 给商家钱包，减少结算金额
     * @param shopId
     * @param changeAmount
     * @param zoneNo
     * @return
     */
    int subSettledAmount(@Param("shopId") Long shopId, @Param("changeAmount") Long changeAmount, @Param("zoneNo") Integer zoneNo);

    /**
     * 锁定未结算金额
     * @param shopId
     * @param shopRealRefundAmount
     * @param zoneNo
     * @return
     */
    int subUnsettledAmount(@Param("shopId") Long shopId, @Param("shopRealRefundAmount") Long shopRealRefundAmount, @Param("zoneNo") Integer zoneNo);

    /**
     * 进行结算
     * 添加结算金额可用金额、结算总金额
     *
     * @param shopId
     * @param settledAmount
     * @param zoneNo
     * @return
     */
    int addSettledAmount(@Param("shopId") Long shopId, @Param("settledAmount") Long settledAmount, @Param("zoneNo") Integer zoneNo);

    /**
     * 根据店铺id求结算金额总和
     * @param shopId
     * @return
     */
    Long getSettleAmountByShopId(@Param("shopId") Long shopId);

    /**
     * 根据店铺id获取分片之后钱包加和的信息
     * @param shopId
     * @return
     */
    ShopWalletVO getShopWalletByZone(@Param("shopId") Long shopId);
}
